﻿using System.Collections.Generic;
using System.Linq;

namespace ComponentAutoBind.Editor
{
    /// <summary>
    /// 默认自动绑定规则辅助器。
    /// </summary>
    public class DefaultAutoBindRuleHelper : AutoBindRuleHelperBase
    {
        /// <summary>
        /// 命名前缀与类型的映射
        /// </summary>
        private static readonly Dictionary<string, string> s_PrefixesDict = new Dictionary<string, string>()
        {
            { "Trans", "Transform" },
            { "OldAnim", "Animation" },
            { "NewAnim", "Animator" },
            { "Rect", "RectTransform" },
            { "Canvas", "Canvas" },
            { "Group", "CanvasGroup" },
            { "VGroup", "VerticalLayoutGroup" },
            { "HGroup", "HorizontalLayoutGroup" },
            { "GGroup", "GridLayoutGroup" },
            { "TGroup", "ToggleGroup" },
            { "Btn", "Button" },
            { "Img", "Image" },
            { "RImg", "RawImage" },
            { "Txt", "Text" },
            { "Input", "InputField" },
            { "Slider", "Slider" },
            { "Mask", "Mask" },
            { "Mask2D", "RectMask2D" },
            { "Tog", "Toggle" },
            { "Sbar", "Scrollbar" },
            { "SRect", "ScrollRect" },
            { "Drop", "Dropdown" },
        };

        private static readonly Dictionary<string, string> s_ReversePrefixesDict =
            new Dictionary<string, string>(s_PrefixesDict.ToDictionary(kvp => kvp.Value, kvp => kvp.Key));

        /// <summary>
        /// 初始化自动绑定规则配置。
        /// </summary>
        public override void InitAutoBindRule()
        {
            m_PrefixesDict = s_PrefixesDict;
            m_ReversePrefixesDict = s_ReversePrefixesDict;
        }
    }
}